package com.com.knowledgepaymentmanagementsystem.controller.marketing;

import com.com.knowledgepaymentmanagementsystem.pojo.marketing.Full;
import com.com.knowledgepaymentmanagementsystem.service.marketing.FullService;
import com.com.knowledgepaymentmanagementsystem.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张攀
 * @version 1.0
 * @description: TODO
 * @date 2025/9/23 下午3:07
 */

@CrossOrigin
@RequestMapping("/full")
@RestController
@Api(tags = "满减满折")
public class FullController {

    @Autowired
    private FullService fullService;

    @ApiOperation(value = "查找满减满折",httpMethod = "POST",notes = "查找满减满折")
    @PostMapping("find")
    public ResultUtil<List<Full>> getFull(@RequestBody Full full){
        try {
            return new ResultUtil<List<Full>>(200,"查找成功",fullService.getFull(full));
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500,"查询失败");
        }
    }

    @ApiOperation(value = "新增满减满折",httpMethod = "POST",notes = "新增满减满折")
    @PostMapping("insert")
    public ResultUtil insertFull(@RequestBody Full full){
        try {
            return new ResultUtil<>(200,"新增成功",fullService.insertFull(full));
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500,"新增失败");
        }
    }

    @ApiOperation(value = "修改满减满折",httpMethod = "PUT",notes = "修改满减满折")
    @PutMapping("update")
    public ResultUtil updateFull(@RequestBody Full full){
        try {
            fullService.updateFull(full);
            return new ResultUtil<>(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500,"修改失败");
        }
    }

    @ApiOperation(value = "删除满减满折",httpMethod = "DELETE",notes = "删除满减满折")
    @DeleteMapping("delete")
    public ResultUtil deleteFull(Integer id){
        try {
            fullService.deleteFull(id);
            return new ResultUtil<>(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500,"修改失败");
        }
    }

}
